package cn.jisol.ngame.util;

public class ToUtil {
    public static int bytesToInt(byte[] bytes){
        return bytes[0] & 0xFF |
                (bytes[1] & 0xFF) << 8 |
                (bytes[2] & 0xFF) << 16 |
                (bytes[3] & 0xFF) << 24;
    }

    public static byte[] intToBytes(int intValue){
        byte[] bytes = new byte[4];
        bytes[0] = (byte) (intValue & 0xff);
        bytes[1] = (byte) ((intValue >> 8) & 0xff);
        bytes[2] = (byte) ((intValue >> 16) & 0xff);
        bytes[3] = (byte) ((intValue >> 24) & 0xff);
        return bytes;
    }

}
